package com.jqsoft.android.facesdk;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.text.method.KeyListener;

import com.jqsoft.android.facesdk.face.FaceDB;
import com.jqsoft.android.facesdk.face.FaceMainActivity;
import com.jqsoft.android.facesdk.newface.MainActivity;
import com.jqsoft.launcher.util.Log;

import java.io.Serializable;

/**
 * Created by zzwang on 2017/12/18.
 */

public class FaceSDKManager {

    private static String faceDBPath;

    public static void setFaceDBPath(String path){
        faceDBPath = path;
    }

    private static FaceSDKManager instance;

    private FaceDB mFaceDB;
    private Uri mImage;

    double Similarity;
    Boolean faceRegister=false;
    Boolean isArcface=false;
    Boolean Arcfacesuccess=false;
    Serializable mpeopleBasebean;
    String sYear,sSignKey;

    public FaceDB getFaceDB() {
        return mFaceDB;
    }

    public double getSimilarity() {
        return Similarity;
    }

    public void setSimilarity(double similarity) {
        Similarity = similarity;
    }

    public Boolean getArcfacesuccess() {
        return Arcfacesuccess;
    }

    public void setArcfacesuccess(Boolean arcfacesuccess) {
        Arcfacesuccess = arcfacesuccess;
    }

    public Boolean getFaceRegister() {
        return faceRegister;
    }

    public void setFaceRegister(Boolean faceRegister) {
        this.faceRegister = faceRegister;
    }
    public Boolean getArcface() {
        return isArcface;
    }

    public void setArcface(Boolean arcface) {
        isArcface = arcface;
    }
    public Serializable getMpeopleBasebean() {
        return mpeopleBasebean;
    }

    public void setMpeopleBasebean(Serializable mpeopleBasebean) {
        this.mpeopleBasebean = mpeopleBasebean;
    }

    public String getsYear() {
        return sYear;
    }

    public void setsYear(String sYear) {
        this.sYear = sYear;
    }

    public String getsSignKey() {
        return sSignKey;
    }

    public void setsSignKey(String sSignKey) {
        this.sSignKey = sSignKey;
    }

    public FaceSDKManager() {
        if(null == mFaceDB){
            mFaceDB = new FaceDB(faceDBPath);
        }
    }

    public static FaceSDKManager getInstance() {
        if(null == instance){
            instance = new FaceSDKManager();
        }
        return instance;
    }

    public void setCaptureImage(Uri uri) {
        mImage = uri;
    }

    public Uri getCaptureImage() {
        return mImage;
    }


    public static void toFaceDetect(Context context,String name,String id,String imagebase64,String photo,Object obj,String pagetype){
        //跳转人脸检测页面需先设置db数据库路径
        String path = context.getFilesDir().getPath();
        Log.d("zzwang",path);
        FaceSDKManager.setFaceDBPath(path);
     //   Intent i = new Intent(context, FaceMainActivity.class);
        Intent i = new Intent(context, MainActivity.class);
        PeopleBaseInfoBean bean = new PeopleBaseInfoBean();
        bean.setCardNo(id);
        bean.setUserName(name);
        bean.setPhotoUrl(imagebase64);
        bean.setIdcardImg(photo);
        i.putExtra("mpeopleBasebean",bean);
        i.putExtra("obj", (Serializable) obj);
        i.putExtra("pagetype",pagetype);
        context.startActivity(i);
    }


}
